package cn.juque.abstractfactory.service;

import cn.juque.methodfactory.service.PipelineService;

/**
 * @author juque
 * @version 1.0.0
 * <ul>
 *     <li>ModelEnum</li>
 * </ul>
 * @date 2023-06-11 14:39:19
 **/
public enum ModelEnum {

    /**
     * enums
     */
    MODEL_3("model3", new ModelThreeTeslaPipelineServiceImpl()),
    MODEL_Y("modelY", new ModelYTeslaPipelineServiceImpl());
    private final String model;

    private final TeslaPipelineService pipelineService;

    ModelEnum(String model, TeslaPipelineService pipelineService) {
        this.model = model;
        this.pipelineService = pipelineService;
    }

    public String getModel() {
        return model;
    }

    public TeslaPipelineService getPipelineService() {
        return pipelineService;
    }

    public static TeslaPipelineService forPipeline(String model) {
        for (ModelEnum modelEnum : ModelEnum.values()) {
            if(modelEnum.getModel().equals(model)) {
                return modelEnum.getPipelineService();
            }
        }
        return null;
    }
}
